const { defineConfig } = require('@vue/cli-service')
const path = require("path");
const ip = process.env.VUE_APP_TYPE === 'prod' ? 'https://scm.fastfish.com' : 'https://scm-pre.fastfish.com'
const oss = process.env.VUE_APP_TYPE === 'prod' ? 'https://sso.fastfish.com/realms/fastfish/protocol/openid-connect/auth' : 'https://sso-pre.fastfish.com/realms/fastfish/protocol/openid-connect/auth'

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave:false,
  publicPath: '/',
  configureWebpack:{
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
  },
  devServer: {
    port: 8000,
    headers: {			// 重点1: 允许跨域访问子应用页面
      'Access-Control-Allow-Origin': '*',
    },
    proxy: {
      '/api': {
        target: ip,
        changeOrigin: true
        // pathRewrite: {
        //   '^/api': ''
        // }
      },
      '/oss': {
        target: oss,
        changeOrigin: true,
        pathRewrite: {
          '^/oss': ''
        }
      },
      '/webapi': {
        target: ip,
        changeOrigin: true,
        pathRewrite: {
          '^/webapi': '/webapi'
        }
      }
    }
  }
})
